#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define	MAX_N	30000

int main() {
	
	bool f[MAX_N + 1];
	int u[MAX_N + 1];
	
	int i, j, c, N;
	
	cin >> N;
	
	for(i = 1; i <= N; i++)
	{
		cin >> u[i];
		f[i] = false;
	}
	
	c = 0;
	for(i = 1; i <= N; i++)
	{
		j = i;
		if(f[j] == false)
		{
			c++;
		}
		while(f[j] == false)
		{
			f[j] = true;
			j = u[j];
		}	
	}
	
	cout << c << endl;
	
	return 0;
}
